package tp.pr5.commands;

import tp.pr5.Game;
import tp.pr5.Map;
import tp.pr5.MensajesConst;
import tp.pr5.Player;
import tp.pr5.commands.exceptions.CommandExecutionException;
import tp.pr5.commands.exceptions.WrongCommandFormatException;

public class HelpCommand implements Command{

	private String _comando;
	
	private Game _game;
	//CONSTRUCTOR
	public HelpCommand()
	{
		
	}
	public HelpCommand(String cad)
	{
		this._comando=cad;		
	}
	public void configureContext(Game g, Map m, Player p) {
		
		this._game=g;
	}
	@Override
	public void execute() throws CommandExecutionException {
		// TODO Auto-generated method stub
		if (this._comando.equalsIgnoreCase("HELP")|| this._comando.equalsIgnoreCase("AYUDA"))
			this._game.requestHelp();
		else
			throw new CommandExecutionException();
		
		
	}

	@Override
	public String getHelp() {
		// TODO Auto-generated method stub
		return MensajesConst.hHelp;
	}

	@Override
	public Command parse(String cad)
			throws WrongCommandFormatException {
		// TODO Auto-generated method stub
		
		String cadena[]= cad.split(" ");
		
		if (cadena.length != 1) throw new WrongCommandFormatException();
		else
		{
			if (cadena[0].equalsIgnoreCase("HELP") || cadena[0].equalsIgnoreCase("AYUDA")) return new HelpCommand(cad);
			else throw new WrongCommandFormatException();
		}
		
	}

}